package API.Class.Collections;

import API.Class.util.Formation;

import java.util.HashMap;
import java.util.Map;

public class SameThreadCollections<T> {
    private T map;
    private final Thread t1;
    private int counts;

    private int times;

    public Thread GetCrateThread() {
        return t1;
    }

    public void SetRuns(int counts) {
        this.counts = counts;
    }

    public void Start(Formation formation) {
        if (times < counts) {
            times++;
            formation.Run();
            times--;
        }
    }

    public boolean isNull() {
        return map == null ? true : false;
    }

    public SameThreadCollections() {
        t1 = Thread.currentThread();
    }

    public SameThreadCollections(T object) {
        t1 = Thread.currentThread();
        map = object;
    }

    public void Add(T object) {
        map = object;
    }

    public T Get() {
        return map;
    }
}
